package com.example.customview.util

import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.view.View

fun View.getBitmap(width: Int, drawable: Int): Bitmap {
    val options = BitmapFactory.Options()
    options.inJustDecodeBounds = true
    BitmapFactory.decodeResource(this.resources, drawable, options)
    options.inJustDecodeBounds = false
    options.inDensity = options.outWidth
    options.inTargetDensity = width
    return BitmapFactory.decodeResource(this.resources, drawable, options)
}